<?php include_once('header.php'); ?>
<?php include_once('left_navigation.php'); ?>	
<?php include_once('../classess/db_connection.php'); ?>
<div class="col-lg-12"><!-- Start Middle Content Div-->
	<div class="box">
		<div class="box-header" data-original-title=""><!-- Start Box Header Div-->
			<h2><i class="fa fa-edit"></i><span class="break"></span>PPT</h2>
			<div class="box-icon">
				<a href="gallery.html#" class="btn-minimize"><i class="fa fa-chevron-up"></i></a>
				<a href="gallery.html#" class="btn-close"><i class="fa fa-times"></i></a>
			</div>
		</div><!-- End Box Header Div-->
		<div class="box-content"><!-- Start Box Content Div-->
			<div class="row">
				<div class="col-sm-4">
					<img src="img/product.jpg" class="product_image" alt="Product Image">
				</div><!--/col-->
				<div class="col-sm-8">
					
					<div id="img_description">
						<?php
							if(isset($_GET['value']) && trim($_GET['value'])!=''){
								
								$split_value = explode('.',$_GET['value']);
								$split_part_first = strlen($split_value['0']);
								$split_part_second = strlen($split_value['1']);

								$course_id = '';
								$file_number = '';
								
								if($split_part_first==7 && $split_part_second==7){
									
									$course_id = substr($split_value['0'],6,1);
									$file_number = substr($split_value['1'],0,1);

								}else if($split_part_first==7 && $split_part_second>=7){
									
									$course_id = substr($split_value['0'],6,1);
									$file_number = substr($split_value['1'],0,2);

								}else if($split_part_first>=7 && $split_part_second==7){
									
									$course_id = substr($split_value['0'],6,2);
									$file_number = substr($split_value['1'],0,1);

								}else if($split_part_first>=7 && $split_part_second>=7){
									
									$course_id = substr($split_value['0'],6,2);
									$file_number = substr($split_value['1'],0,2);
								}
								
								$select_course = "SELECT * FROM tbl_courses WHERE id='".$course_id."'";
								$query_course = mysql_query($select_course) or die(mysql_error());
								$row = mysql_num_rows($query_course);
								if($row>0){
									$crs_name = '';
									$crs_ext = '';
									while($data = mysql_fetch_array($query_course)){
										$crs_name = $data['course_name'];
										$sel_file_name = "SELECT * FROM tbl_course_ppt WHERE course_id='".$course_id."' ORDER BY `id` ASC";
										$query_file_name = mysql_query($sel_file_name) or die(mysql_error());
										$row_file_name = mysql_num_rows($query_file_name);
										$count =0;
										if($row_file_name>0){
											while($data_file_name = mysql_fetch_array($query_file_name)){
												if($count == $file_number){
													$ext = $data_file_name['file_name'];
													$crs_ext = explode('.',$ext);
												}
												$count++;
											}
										}
									}
									
									echo '<iframe src="http://docs.google.com/gview?url=http://rvtraining.net/admin/dashboard/course_ppt/'.$crs_name.'/'.$course_id.'_'.$file_number.'.'.$crs_ext['1'].'&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>';
								}else{
									echo 'something wrong in url';
								}
							}else{
								echo 'Wrong Url';
							}
						?>
					</div>
					
				</div><!--/col-->
			</div><!-- End Row div -->
		</div><!-- End Box Content Div -->
	</div><!-- End Box Div-->
</div><!-- End Middle Content Div-->
<?php include_once('footer.php'); ?>
<script type="text/javascript">
	$(document).ready(function(){
		/*	=============== Function for right click close starts here ================== */
			$(function () {
				$(document).bind("contextmenu",function(e){
					e.preventDefault();				
				});
			});
		/*	=============== Function for right click close ends here ==================		*/

		/*	=============== Function for ctrl+u, ctrl+s, ctrl+c close starts here ==================	*/
			document.onkeydown = function(e) {
				//alert(e.keyCode);
				if(e.keyCode===16 || e.keyCode===74){
					//alert('ctrl+shift+j');
				}
				if(e.keyCode===83){
					//alert('s');
				}
				if(e.keyCode===67){
					//alert('c');
				}
				if(e.keyCode===85){
					//alert('u');
				}

				/*if (e.keyCode === 67 || e.keyCode === 86 || e.keyCode === 85 ||     e.keyCode === 117 || e.keycode === 17 || e.keycode === 85){
					alert('not allowed');
				}*/
				return false;
			};
		/*	=============== Function for ctrl+u, ctrl+s, ctrl+c close ends here ==================		*/
	});
</script>